home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
PC Gamer (Italian) 30
/
PC Gamer IT CD 30 1-2.iso
/
MOTS
/
GAMEDATA
/
RESOURCE
/
JKMRES.GOO
/
cog_force_jump.cog
< prev
next >
Wrap
Text File
|
1998-02-25
|
5KB
|
202 lines
# Jedi Knight Cog Script
#
# FORCE_JUMP.COG
#
# FORCEPOWER Script - Force Jump
# Basic Power
# Bin 21
#
# This ability is controlled by the length of the key press.
#
# [YB]
#
# (C) 1997 LucasArts Entertainment Co. All Rights Reserved
symbols
thing player local
vector upVel local
vector playerVel local
vector newVel local
flex cost=20.0 local
flex mana local
flex jump local
flex duration local
flex maxDuration local
int rank local
int attachFlags local
sound jumpSound=ForceJump01.wav local
sound jumpSound2=ForceJump02.wav local
int channel=-1 local
flex soundduration local
int inbubble=0 local
message startup
message activated
message deactivated
message pulse
message newplayer
message timer
message killed
message selected
message enterbubble
message exitbubble
end
# ========================================================================================
code
startup:
player = GetLocalPlayerThing();
inbubble = 0;
SetPulse(0);
SetInvActivated(player, 21, 0);
soundduration = GetSoundLen(jumpSound);
Return;
# ........................................................................................
activated:
if(inbubble) Return;
// No jumping with the EWEB
if (GetCurWeapon(player) == 10) Return;
if(IsInvActivated(player, 21)) Return;
SetInvActivated(player, 21, 1);
mana = GetInv(player, 14);
if(mana >= cost || GetInv(player, 14) >= GetInv(player, 69))
{
channel = PlaySoundThing(jumpSound, player, 1.0, -1, -1, 0x80);
ActivateBin(player, 0, 21);
SetPulse(0.5);
}
Return;
# ........................................................................................
deactivated:
// No jumping with the EWEB
if (GetCurWeapon(player) == 10) Return;
duration = DeactivateBin(player, 21);
SetInvActivated(player, 21, 0);
SetPulse(0);
if(inbubble) Return;
if(duration < soundduration)
{
if(channel != -1)
{
StopSound(channel, 0.0);
channel = -1;
}
}
rank = GetInv(player, 21);
maxDuration = rank * 0.35;
// Must be attached to a world surface or thing face or on the surface of water.
attachFlags = GetAttachFlags(player);
if((attachFlags & 1) || (attachFlags & 2) || (GetPhysicsFlags(player) & 0x100000))
{
mana = GetInv(player, 14);
if(mana >= cost || GetInv(player, 14) >= GetInv(player, 69))
{
PlaySoundThing(jumpSound2, player, 1.0, -1, -1, 0x80);
if(GetInv(player, 64) != 1) ChangeInv(player, 14, -cost);
// Send a "force disturbance"...
if(!IsMulti())
SendMessageExRadius(GetThingPos(player), cost, 0x4, splash, 21, 0, 0, 0);
// If we tap or hold to max, then do max jump.
if((duration < 0.15) || (duration > maxDuration))
duration = maxDuration;
// Flash the twinkling stars effect
if(!(jkGetFlags(player) & 0x20))
{
jkSetPersuasionInfo(player, 14, 22);
jkSetFlags(player, 0x20);
SetTimerEx(0.33, player, 0, 0);
}
jump = duration + 2.5;
upVel = VectorSet(0.0, 0.0, jump);
playerVel = GetThingVel(player);
newVel = VectorAdd(upVel, playerVel);
DetachThing(player);
SetThingVel(player, newVel);
ClearPhysicsFlags(player, 0x100000);
}
}
Return;
# ........................................................................................
pulse:
if(GetThingHealth(player) < 1)
{
if(channel != -1) StopSound(channel, 0.1);
SetPulse(0);
}
Return;
# ........................................................................................
selected:
jkPrintUNIString(player, 21);
Return;
# ........................................................................................
killed:
if(GetSenderRef() != player) Return;
newplayer:
SetPulse(0);
SetInvActivated(player, 21, 0);
Return;
# ........................................................................................
enterbubble:
inbubble = 1;
//call stop_power;
Return;
# ........................................................................................
exitbubble:
inbubble = 0;
Return;
# ........................................................................................
timer:
jkClearFlags(GetSenderId(), 0x20);
Return;
end